<%@page import="cn.egame.ext.EnumTypeExt"%>
<%@page import="org.springframework.context.annotation.Bean"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="cn.egame.common.model.PageData"%>
<%@page import="java.util.List"%>
<%@page import="cn.egame.ext.op.OperationActivityInfo"%>
<%@page import="com.egame.manage.biz.server.pu.ParameterServiceImpl"%>
<%@page import="cn.egame.common.util.Utils"%>
<%@page import="com.egame.manage.biz.server.UserServiceImpl"%>
<%@page import="com.lenovo.manager.business.domain.UserBean"%>
<%@page import="com.egame.manage.biz.utils.ConstVar"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="<%=request.getContextPath()%>/css/main.css"  />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		if(($("#typeNum").val()!=0)&&($("#typeNum").val()!=-1)) {
			var manu = $("#typeNum").val();
			$("#recordTypeNum").val(manu);
		}
		
		if(($("#adPos").val()!=0)&&($("#adPos").val()!=-1)) {
			var scrp = $("#adPos").val();
			$("#position").val(scrp);
		}
	});

	function search(){
		document.getElementById("myform").action = "<%=request.getContextPath() + "/tv/activity/list.do" %>";
		document.getElementById("myform").submit();
	}
</script>
<title>广告活动列表</title>
</head>
<body>
<% 
	String banner = "";
	if((request.getAttribute("banner")!=null)&&(request.getAttribute("banner") != "")){
		banner = (String)request.getAttribute("banner");
	}
	String beginTime = "";
	if((request.getAttribute("beginTime")!=null)&&(request.getAttribute("beginTime") != "")){
		beginTime = (String)request.getAttribute("beginTime");
	}
	String endTime = "";
	if((request.getAttribute("endTime")!=null)&&(request.getAttribute("endTime") != "")){
		endTime = (String)request.getAttribute("endTime");
	}
%>
<form action="" id="myform">	
<input type="hidden" name=para value=0>
	<div class="matter_box">
		<h3 class="nopoint"><strong>广告活动列表</strong></h3>
		<% 
			int typeNum=0;
			if((request.getAttribute("typeNum") != null)&&(Integer.parseInt(request.getAttribute("typeNum").toString())!=0)) {
				typeNum =  Integer.parseInt(request.getAttribute("typeNum").toString());
			}
		%>
		<input id="typeNum" type="hidden" value="<%=typeNum %>"/>
		<%
			int adPos=0;
			if((request.getAttribute("adPos") != null)&&(Integer.parseInt(request.getAttribute("adPos").toString())!=0)) {
				adPos =  Integer.parseInt(request.getAttribute("adPos").toString());
			}
		%>
		<input id="adPos" type="hidden" value="<%=adPos%>"/>
		
		<div class="task_search">
            	<span>广告标题：</span> 
				<input id="advert_banner" name="banner" class="input" type="text" value=<%=banner %>>
				<span>广告类型：</span>
				<select name="recordTypeNum" id="recordTypeNum">
				    <option value="0" >请选择</option>
					<option value="1" >广告</option>
					<option value="2" >活动</option>
				</select>
				<span>广告位置：</span>
				<select name=position id="position">
					<option value=0>请选择</option>
					<option value=1>热门</option>
					<option value=2>新品</option>
					<option value=4>加载页面</option>
					<option value=5>弹出广告</option>
				</select>

				<span>开始时间：</span>				
				<input type="text" name="beginTime" id="advert_beginTime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="Wdate" readonly="readonly" value="<%=beginTime %>">
				<span>结束时间：</span>
				<input type="text" name="endTime" id="advert_endTime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" readonly="readonly" value="<%=endTime %>">
				<span>
	        		<input type=button value="查询" onclick="search()" class="upload_btn">
	        	</span>
          	</div>
		
		<p class="tr">
			<a class="btn2" href="<%=request.getContextPath() + "/tv/activity/history/list.do" %>">历史记录</a>
			<a class="btn2" href="<%=request.getContextPath() + "/tv/activity/set/show.do" %>">新增</a>
		</p>
		<div class="matter_text clearfix nobg mart">
			<table cellpadding="0" cellspacing="0" class="table2" id="rights_list">
				<tr class="first">
					<th>位置</th>
					<th>标题</th>
					<th>类型</th>
					<th>开始时间</th>
					<th>结束时间</th>
					<th>操作人</th>
					<th>操作时间</th>
					<th>操作</th>
				</tr>
	<%
		if(request.getAttribute("pd")!= null){
			PageData pd = (PageData) request.getAttribute("pd");
			if(pd.getContent()!=null){
				List<OperationActivityInfo> list = (List<OperationActivityInfo>)pd.getContent();
				for(OperationActivityInfo bean:list){
					%>
					<tr>
						<td align=center><%=EnumTypeExt.OperationActivityPosition.lookup(bean.getPosition()).getMessage() %></td>
						<td align=center><%=bean.getDescription() %></td>
						<td align=center><%=(bean.getRecordType()).getMessage() %></td>
						<% 
							String time = "";
							if(bean.getBeginTime() != null){
								time = Utils.toDateString(bean.getBeginTime(),"yyyy-MM-dd hh:mm:ss");
							}
							String endtime = "";
							if(bean.getEndTime() != null){
								endtime = Utils.toDateString(bean.getEndTime(),"yyyy-MM-dd hh:mm:ss");
							}
							String operatetime = "";
							if(bean.getUpdateTime() != null){
								operatetime = Utils.toDateString(bean.getUpdateTime(),"yyyy-MM-dd hh:mm:ss");
							}
						%>
						<td align=center><%=time %></td>
						<td align=center><%=endtime %></td>
						<td align=center><%=UserServiceImpl.getInstance().getCnNameById(bean.getOperatorId()) %></td>
						<td align=center><%=operatetime %></td>
						<td align=center>
						<% 
							int para=0;
							if((request.getAttribute("para") != null)&&(Integer.parseInt(request.getAttribute("para").toString())!=0)) {
								para =  Integer.parseInt(request.getAttribute("para").toString());
							}
						%>
							<a href="<%=request.getContextPath() + "/tv/activity/edit/show.do?id=" + bean.getId() %>">编辑</a>
							<a href="<%=request.getContextPath() + "/tv/activity/delete.do?para="+para+"&id=" + bean.getId() %>">删除</a>
							<a href="<%=request.getContextPath() + "/tv/activity/adapt/show.do?id=" + bean.getId() %>">适配机型</a>
						</td>
							
					</tr>
					<%
				}
			}
		}
	%>
</table>
<%@ include file="../page.in"  %> 
</div>
</div>
</form>
</body>
</html>